export function formatDateTime(date) {
    if (date === "" || !date) {
        return "";
    }
    var newDate = new Date(date);
    var y = newDate.getFullYear();
    var m = newDate.getMonth() + 1;
    m = m < 10 ? ('0' + m) : m;
    var d = newDate.getDate();
    d = d < 10 ? ('0' + d) : d;
    var h = newDate.getHours();
    h = h < 10 ? ('0' + h) : h;
    var minute = newDate.getMinutes();
    minute = minute < 10 ? ('0' + minute) : minute;
    var second = newDate.getSeconds();
    second = second < 10 ? ('0' + second) : second;
    return y + '-' + m + '-' + d + ' ' + h + ':' + minute + ':' + second;
}

export function overflowHidden(str){
    if(str.length > 20) return str.slice(0,20) + "..."
    else return str
}

export function getAssetsImages(name) {
    return new URL(`/src/assets/images/${name}`, import.meta.url).href;
}